// 添加视频纹理
import * as BABYLON from "babylonjs"; //全部引入

function addVideoTex(scene) {
  let heXieBuilding = scene.getMeshByName("和谐广场南座");
  console.log(heXieBuilding.position, "和谐");
  // 平面配置项
  let planeOpts = {
    height: 0.19,
    width: 0.33,
    sideOrientation: 0
  };
  // 创建平面物体，后续给这个物体添加纹理材质
  let videoPlane = BABYLON.MeshBuilder.CreatePlane("plane", planeOpts, scene);
  // 平面物体位置参数
  let vidPos = new BABYLON.Vector3(-2.04, 0.2, -1.05).addInPlace(
    heXieBuilding.position
  );
  videoPlane.position = vidPos;
  videoPlane.rotation.y = Math.PI / 2;
  let videoPlaneMat = new BABYLON.StandardMaterial("m", scene);
  let videoPlaneVidTex = new BABYLON.VideoTexture(
    "vidtex",
    // "https://playground.babylonjs.com/textures/babylonjs.mp4",
    "static/textures/feng.mp4",
    scene
  );
  videoPlaneMat.diffuseTexture = videoPlaneVidTex;
  videoPlaneMat.roughness = 1;
  videoPlaneMat.emissiveColor = new BABYLON.Color3.White();
  videoPlane.material = videoPlaneMat;
}

export default addVideoTex;
